source ../scripts/adi_env.tcl
source $ad_hdl_dir/library/scripts/adi_ip.tcl

set p_device "x*"
set src_dir "./src"   
set sim_dir "./sim/tb"   

set src_files [glob -nocomplain -directory $src_dir *.v*]
set sim_files [glob -nocomplain -directory $sim_dir *.v]

set filtered_list []
foreach f $src_files {
  if {[file isfile $f]} {
    lappend filtered_list [file normalize $f]
  }
}
puts "======== File List ========"
foreach f $filtered_list {
  puts "  - $f"
}
puts "=========================="

adi_ip_create_w_device axi_gt_common_sdm
adi_ip_files axi_gt_common_sdm $filtered_list
add_files -fileset sim_1 -norecurse $sim_files

adi_ip_properties_lite axi_gt_common_sdm

proc group_other { } {
    
}

proc main { } {
    global ad_hdl_dir
    ipx::infer_bus_interfaces xilinx.com:interface:aximm_rtl:1.0 [ipx::current_core]

    set_property name AXI_LITE [ipx::get_bus_interfaces s_axi -of_objects [ipx::current_core]]
    set_property value AXI_LITE [ipx::get_bus_parameters ASSOCIATED_BUSIF -of_objects [ipx::get_bus_interfaces s_axi_aclk -of_objects [ipx::current_core]]]

    #group_other

    ipx::save_core [ipx::current_core]
    update_ip_catalog -rebuild -repo_path $ad_hdl_dir/library
    
    file copy -force axi_gt_common_sdm_v1_0.tcl ./xgui/axi_gt_common_sdm_v1_0.tcl
}

main
 

